<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="${ctx}/css/sapar.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/css/common.css" />

<script type="text/javascript" src="${ctx}/js/jquery.js"></script>
<script type="text/javascript" src="${ctx}/js/sapar.js"></script>
<script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
<script type="text/javascript" src="${ctx}/js/mask.js"></script>
<script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
<script type="text/javascript">
	function getSelRecord(){
		var chk_value =[];
	   $('input[name="key"]:checked').each(function(){
			chk_value.push($(this).val()); 
		});
		return chk_value;
	}  
  
	//{depart:,package:,num:}

</script>
<style>

.add-box-first{
float:left;
}
.add-box-second{
float:left;
}
th{
border:1px solid #bdd0db;
}
#one{
width:200px;
}
#two{
width:200px;
}
#three{
width:170px;
}
#five{
width:200px;
}
#six{
width:200px;
}

#oneone{
width:200px;
}
#twotwo{
width:200px;
}

#threethree{
width:200px;
}

#fourfour{
width:200px;
}
#fivefive{
width:170px;
}
.gui-input{
width:97%;

margin-left:0px;
}
.table .table-operate a.buttona{background: #EFF6FA url("../../images/addico.png") no-repeat 4px 6px;
height: 30px;
text-align: center;
line-height: 30px;
width: 65px;
border-radius: 5px;
box-shadow: 1px 2px 3px;
margin-left: 15px;
margin-top: 5px;}

.table .table-operate a.buttona2{
 background: #EFF6FA url("../../images/delico.png") no-repeat 4px 6px;
height: 30px;
text-align: center;
line-height: 30px;
width: 65px;
border-radius: 5px;
box-shadow: 1px 2px 3px;
margin-left: 15px;
margin-top: 5px;
}
</style>


<title>团队票申请</title>
</head>

<body>
	<!-- 遮罩层 -->
	<div id="mask" class="mask"></div> 
    <div id="saper-container">
        <div id="saper-hd"></div>
        <div id="saper-bd">
        	<form class="create-order">
            <div class="subfiled clearfix">
                <h2>有条码回收</h2>
            </div>
            <div class="subfiled-content">
                     <!--表格开始-->
                <div class="user_management">
	                   <div class="subfiled-style2 clearfix">
                          <h2>包信息</h2>
                       </div>	
	                   <div class="table">
	                    <!--表格操作-->
	                    <div class="table-operate ue-clear" id="martop">
	                    	<a href="javascript:;" class="add buttona" id="addpack">新增回收包</a>
	                        <a href="javascript:;" class="del buttona2">全部删除</a>
	                    </div>
	                    <!--表格具体内容-->
	                    <div class="table-box">
	                        <table id="tpaTable">
	                            <thead>
	                                <tr> 
	                                	<th id="five">网篮条码</th>
	                                	<th id="six">包条码</th>
	                                	<th id="one">科室</th>
	                                    <th id="two">包名称</th>
	                                	<th id="three">包数量</th>
	                                    <th id="four">操作</th>
	                                </tr>
	                            </thead>
	                            <tbody id= "tpaTableBaby">
	                            	<tr class="no-data package"><td colspan="10">暂时没有数据</td></tr>
	                            </tbody>
	                        </table>
	                    </div>
	                </div><!--表格结束-->
                </div>     
                <!-- 缺失登记 -->
                <div class="user_management">
	                   <div class="subfiled-style2 clearfix">
                        <h2>缺失信息</h2>
                      </div>
	                     <div class="table">
			                <div class="table-box">
			                     <table id="queshiTable">
			                            <thead>
			                                <tr>
			                                    <th id="oneone">缺失包名称</th>
			                                  	<th id="twotwo">缺失器械</th>
			                                    <th id="threethree">器械大小</th>
			                                    <th id="fourfour">器械形状</th>
			                                    <th id="fivefive">缺失数量</th>
			                                    <th>操作</th>
			                                </tr>
			                            </thead>
			                            <tbody>
			                                <tr class="no-data product"><td colspan="10">暂时没有数据</td></tr>
			                            </tbody>
			                      </table>
			                </div>
                         </div>
	                </div>
                <!-- 人员信息录入 -->
                <div class="user_management">
	                  <div class="subfiled-style2 clearfix">
                        <h2>人员信息</h2>
                      </div>
                      <div class="add-box clearfix" id="jiaojie">
                        <div class="kv-item clearfix">
                            <label>交接人：</label>
                            <div class="kv-item-content">
                                <input type="text" name="huishouJiaojierenTiaoma" id="huishouJiaojierenTiaoma"placeholder="交接人" min="1" maxlength="22" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                            </div>
                        </div>
                        <div class="baocun">
                            <div class="kv-item clearfix">
	                            <label>回收人：</label>
	                            <div class="kv-item-content">
	                                <input type="text"  name="huishouHuishourenTiaoma" id="huishouHuishourenTiaoma" placeholder="回收人" min="1" maxlength="22" onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
	                            </div>
                            </div>
	                        <div class="kv-item clearfix">
	                            <div class="kv-item-content" style="margin-left:5px">
	                                <a href="javascript:;"    class="sapar-btn sapar-btn-recom query-btn" id="save" >保存</a>
	                            </div>
	                        </div>
                        </div>
                    </div>
	            </div>
            </div>
            </form>
        </div>
        <div id="saper-ft" ></div>
    </div>
     
</body>

<script type="text/javascript">

$('select').iSelect();

//判断是否为空
function isNullOrEmpty(strVal){
	if(strVal !=null ){
		strVal = strVal.replace(/(^\s*)|(\s*$)/g,"");
	}
	if(strVal == '' || strVal == null || strVal == undefined){
		return true;
	}else{
		return false;
	}
}

$(function(){
	$(".add").click(function(){
		$("input[name='packNum']");
		layer.open({
			  type: 2,
			  title: '医疗包明细',
			  maxmin: true,
			  shadeClose: true, //点击遮罩关闭层
			  area : ['800px' , '520px'],
			  content: "${ctx}/page/huishou/huishou_barcode.jsp"
			  });
	});
	//点击全部删除
	$(".del").click(function(){
		layer.confirm('你确定要删除全部包么？', function(index){
			$("#tpaTable tbody").empty();
			layer.close(index);
		});
		
	});

	$("#save").mouseover(function(){
		$("#save").css("background","#467735");
	});
	
	$("#save").mouseleave(function(){
		$("#save").css("background","#6ab96e");
	});
	$(".delpack").live("click",function(){
		$(this).parent().parent().remove();;
	});
	$(".query-btn").click(function(){
		var check = true;
 		var huishouJiaojierenTiaoma = $("input[name='huishouJiaojierenTiaoma']").val();
 		var huishouHuishourenTiaoma = $("input[name='huishouHuishourenTiaoma']").val();
 		$(".no-data").remove();

 		//判断是否有包
 		if($("#tpaTableBaby tr").length==0){
 			check = false;
 			alert("请添加包信息");
 		}
 		
 		if(isNullOrEmpty(huishouJiaojierenTiaoma)){
 			check = false;
 			alert("回收交接人不能为空");
 		}
 		if(isNullOrEmpty(huishouHuishourenTiaoma)){
 		    check = false;
 		    alert("回收人不能为空");
		}

 		$('input[name="productqueshiNum"]').each(function(){
			if(isNullOrEmpty($(this).val())){
				check = false;
				alert("缺失数量不能为空");
			}
		});
 		
 		if(check){
 //			$.myloading();
 			showMask();
 			$(".query-btn").css("opacity","0.2");
 			$.ajax({
 	            type: "POST",
 	            url:"${ctx}/wutiaoma/savePack.do",
 	            data:$('.create-order').serialize(),// 你的formid
 	            error: function(request) {
 	           	 layer.alert("网络故障，请稍后再试!");
 	            },
 	            success: function(data) {
//	             $.myloading("hide");
				 $("#mask").hide();
 	           	 if(data.status=="true"){
 	           		 layer.alert("回收成功,点击确定继续回收", function(index){
 	           			window.location.href='huishou_youtiaoma.jsp';
 	           		});
 	           		 window.location.reload();
 	           	 }else{
 	           		 layer.alert(data.msg);
 	           	 }
 	            }
 	        });
 		}
 	});
	//跟据包回收
	

});

$(document).keydown(function(event){
    var oPlay0 = document.getElementById("audio");
    var oPlay1 = document.getElementById("audio1");
    var huishouJiaojierenTiaoma = $("input[name='huishouJiaojierenTiaoma']").val();
    var huishouHuishourenTiaoma =  $("input[name='huishouHuishourenTiaoma']").val();
    if(event.keyCode==13){
        if($("#huishouJiaojierenTiaoma").is(":focus") && !isNullOrEmpty(huishouJiaojierenTiaoma)){
            $("#huishouHuishourenTiaoma").focus();
        }
        if($("#huishouHuishourenTiaoma").is(":focus") && !isNullOrEmpty(huishouHuishourenTiaoma)){
            $(".query-btn").click();
        }

    }
});




//点击table 右键删除行
function del(id){
	$("#"+id).remove();
}

function delqueshi(id){
	$("#"+id).remove();
}
//点击查询明细
function detail(id,name){
	layer.open({
		  type: 2,
		  title: name+'包明细',
		  maxmin: true,
		  shadeClose: true, //点击遮罩关闭层
		  area : ['800px' , '520px'],
		  content: '${ctx}/wutiaoma/findQixieList.do?id='+id+'&name='+name
		  });
}
//iframe界面的 回调函数
//接受条码枪的录入
function callbackPackData(data,lan){
	$(".package").remove();
	var baoArr = data;
	var wanglan = lan;
	$.ajax({
        type: "POST",
        url:"${ctx}/youtiaoma/findmuban.do",
        //将json对象装换
        data:{"dataList":JSON.stringify(baoArr),"wanglan":wanglan},
        error: function(request) {
       	 layer.alert("网络故障，请稍后再试!");
        },
        success: function(data) {
       	 if(data.status=="true"){
             $("#huishouJiaojierenTiaoma").focus();
       		 var tbPackList = data.zsPackageImformation;
       		 var wanglan = data.wanglan;
       		 var depMap = data.depMap;
       		 var str = "";
       		 for(var i = 0;i<tbPackList.length;i++){
       		     var package = tbPackList[i];
                 var keshiName= "";
                 if(package!=null){
                     if (package.packageKeshi !== null) {
                         keshiName = depMap[package.packageKeshi];
                     } else {
                         keshiName = ""
                     }
                     if(keshiName==undefined||keshiName==""||keshiName==null){
                         package.packageKeshi == 15;
                         keshiName ="手术室";

                     }

                     str += "<tr class='softdata'  id='"+package.packageTiaoma+"' ><td><input type='hidden' name='packWl' value='"+wanglan+"'/>"+wanglan+"</td>"
                         +"<td><input type='hidden' name='packTm' value='"+package.packageTiaoma+"'/>"+package.packageTiaoma+"</td>"
                         +"<td><input type='hidden' name='packageKeshi' value='"+package.packageKeshi+"'/><input type='hidden' name='packId' value='"+package.packageId+"'/>"+keshiName+"</td>"
                         +"<td><input type='hidden' name='packName' value='"+package.packageName+"'/>"+package.packageName+"</td>"
                         +"<td>1</td>"
                         +"<td><a href='javascript:;'  class='delpack' >删除</a>&nbsp;&nbsp;<a href='javascript:;' onclick='detail(\""+package.packageId+"\",\""+package.packageName+"\")'>查看明细</a></td></tr>";
                 }

             }
             $("#tpaTableBaby").append(str);
//         <input type='text' name='packNum' value='"+1+"'/>
//       		 for(var key in tbPackList){
//                 var lan = key;
//                 var package = tbPackList[key];
//                 debugger
//                 str += "<tr class='softdata'  id='"+package.packageTiaoma+"' ><td><input type='hidden' name='packWl' value='"+lan+"'/>"+lan+"</td>"
//                     +"<td><input type='hidden' name='packTm' value='"+package.packageTiaoma+"'/>"+package.packageTiaoma+"</td>"
//                     +"<td><input type='hidden' name='packId' value='"+package.packageId+"'/>"+'手术室'+"</td>"
//                     +"<td><input type='hidden' name='packName' value='"+package.packageName+"'/>"+package.packageName+"</td>"
//                     +"<td>"+1+"</td>"
//                     +"<td><a href='javascript:;'  class='delpack' >删除</a>&nbsp;&nbsp;<a href='javascript:;' onclick='detail(\""+package.packageId+"\",\""+package.packageName+"\")'>查看明细</a></td></tr>";
//             }
       	 }else{
       		 layer.alert(data.msg);
       	 }
        }
   	});
}

//function checkPackstr(data){
//	var wltm = data.lan;
//	var pktm = data.bao;
//
//
//}

//iframe界面的 回调函数
$(document).ready(function(){
	layer.open({
		  type: 2,
		  title: '回收扫码',
		  maxmin: true,
		  shadeClose: false, //点击遮罩关闭层
		  area : ['800px' , '520px'],
		  content: '${ctx}/page/huishou/huishou_barcode.jsp'
		  });
	
});

</script>
</html>